package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.EmployeeIncome;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;
import java.util.Map;

public interface EmployeeIncomeMapper {
    int deleteByPrimaryKey(Integer id);

    int insert(EmployeeIncome record);

    int insertSelective(EmployeeIncome record);

    EmployeeIncome selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(EmployeeIncome record);

    int updateByPrimaryKey(EmployeeIncome record);

    List<Map<String, Object>> getMyIncomes(@Param("customerId") String customerId);

    List<Map<String,Object>> getMyIncomesList(@Param("customerId") String customerId, 
                                              @Param("start") Integer start, 
                                              @Param("end") Integer size, 
                                              @Param("startTime") String startTime, 
                                              @Param("endTime") String endTime);
    
    Integer getMyIncomeAmount(@Param("customerId") String customerId, 
                              @Param("startTime") String startTime, 
                              @Param("endTime") String endTime);

    Integer getEmployeeInComeMoney(@Param("customerId") String customerId, 
                                   @Param("startTime") String startTime, 
                                   @Param("endTime") String endTime);

    //通过订单号查询此订单是否产生了员工收益
    EmployeeIncome getEmployeeIncomeByOrderNumber(String orderNumber);

    //定时任务--修改用户可提现金额(分组查询每个员工目前可提金额)
    List<Map<String, Object>> getCanCashMoney();

    //修改已超过退货时效订单状态为1
    @Update("update c_employee_income  set money_status='1' " +
            "where order_number in " +
            "(select a.order_number from (select  ei.order_number from  c_employee_income ei where DATE_ADD( ei.create_time, INTERVAL 7 DAY ) < now()) a)")
    int updateStatus();


}